package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC2006 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int countKDifference(int[] nums, int k) {
            Map<Integer, Integer> seen = new HashMap<>();
            int ans = 0;
            for (int num : nums) {
                if (seen.containsKey(num + k)) {
                    ans += seen.get(num + k);
                }
                if (seen.containsKey(num - k)) {
                    ans += seen.get(num - k);
                }
                seen.put(num, seen.getOrDefault(num, 0) + 1);
            }
            return ans;
        }
    }

    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC2006 an = new LC2006();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
